package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 核销状态
 * @author jyh
 * @version v1.0
 * @date 2021/01/04 22:00
 * @since v1.0
 */
@Getter
public enum WriteOffStatusEnum {


    //已核销
    WRITTEN_OFF("1","enum.writeOffStatus.name.written_off","writtenOff"),
    //已退回
    RETURNED("2","enum.writeOffStatus.name.returned","returned")
    ;
    private String code;
    private String name;
    private String attr;


    WriteOffStatusEnum(String code, String name, String attr) {
        this.code = code;
        this.name = name;
        this.attr = attr;
    }
    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    /**
     * 通过枚举 code 获得枚举
     *
     * @param code 枚举Code
     *
     * @return TransferStatusEnum
     */
    public static String getByCode(String code) {
        for (WriteOffStatusEnum value : WriteOffStatusEnum.values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value.getName();
            }
        }
        return "";
    }
}
